package com.example.tupu.repository;

import com.example.tupu.entity.Town;
import com.example.tupu.relationship.ReBirthplace;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface BirthplaceRepository extends Neo4jRepository<ReBirthplace,Long> {
    List<ReBirthplace> findAllByTitle(String title);

    List<ReBirthplace> findAllByTitleLike(String title);
    @Query("MATCH (n:Town) WHERE n.title =~ ('.*'+$title+'.*') RETURN n")
    Town findBplaceTitle(String title);

    @Query("MATCH (n:Figure)-[d:BIRTHPLACE_IN]->(m:Town) where n.title=$title return m")
    List<Town> findTownByFigure(String title);
}
